 {% extends "layout.html" %}




{% block head %}
  {% endblock %}


   {% block right%}
<style>
    #loading {
        width:200px;
        height: 30%;
        position: relative;
        left: 50%;
        margin-top: 2%;
        z-index:10000;
        line-height:25px;
        vertical-align:middle;
        font-size:11pt;
        display:none;
    }

    .layui-table td {
        min-width: 700px;
    }
    .layui-table th {
         text-align:center;
         min-width: 150px;
         background-color:#f2f2f2;
    }
    .layui-btn {
        display: inline-block;
        height: 38px;
        line-height: 38px;
        padding: 0 50px;
        background-color: #009688;
        color: #fff;
        white-space: nowrap;
        text-align: center;
        font-size: 14px;
        border: none;
        border-radius: 2px;
        cursor: pointer;
        margin-left: 50%;
        margin-top: 5%;
    }
</style>

 <div class="layui-fluid" id="mender" title={{session["user_id"]}}>
    <div class="layui-row layui-col-space15"  id="menderPower" title={{session["power"]}}>
        <div class="layui-col-md12">
            <div class="layui-card">


                <div class="layui-card-body layui-table-body layui-table-main" style="height: 800px">
                    <form action="/alter_all01" method="post">
                    <table class="layui-table layui-form">
                        <tbody>
							<input name="menderPower" hidden value={{session["power"]}} >
                            <tr>
                                <th>
                                        爬取网址
                                </th>
                                  <td>
								  <input  id="setting_url" name="desc" class="layui-input" value="{{management_alter[0][1]}}">
								</td>
                            </tr>
                            <tr>
                                <th>
                                        休眠时间
                                </th>
                                 <td>
								    <input name="time" id="setting_" value={{management_alter[1][1]}} class="layui-input">
								</td>
                            </tr>
                            </tr>
                            <tr>
                                <th>
                                        IP更换步长
                                </th>
                                <td>
								    <input name="ip" value={{management_alter[2][1]}} class="layui-input">
								</td>
                            </tr>
                            </tr>
                            <tr>
                                <th>
                                        爬取范围
                                </th>
                                <td>
                                    <select  lay-filter="business1"  title= {{management_alter[3][1]}}
                                             class="select"  lay-verify="type" name="business1"   >
                                          {% if management_alter[3][1] == "p" %}
                                        <option  value="p" selected  >省</option>
                                        <option  value="w" >全国</option>
                                        {% else %}
                                        <option  value="p"   >省</option>
                                        <option  value="w" selected >全国</option>
                                          {% endif %}
                                    </select>
							    </td>
                            </tr>
                            <tr>
                                <th>
                                        范围为"省"可指定省份
                                </th>
                                 <td>
                                    <select  lay-filter="business2"  lay-search  title= {{management_alter[4][1]}}
                                             class="select"  lay-verify="type" name="business2"   >
                                        <option  value={{management_alter[4][1]}} selected  >{{management_alter[4][1]}}</option>
                                        {% for i  in  province %}
                                        <option  value={{ i[0] }}   >{{ i[0] }} </option>
                                        {% endfor  %}
                                    </select>
							    </td>
                            </tr>
                            <tr>
                                <th>
                                        获取IP地址
                                </th>
                                <td>
                                  <input   name="get_ip" class="layui-input" value="{{management_alter[5][1]}}">
                                </td>
                            </tr>
                            <tr>
                                <th>
                                        起始页
                                </th>
                                <td>
                                    <input name="start" value={{management_alter[7][1]}} class="layui-input">
                                </td>
                            </tr>
                            <tr>
                                <th>
                                        结束页
                                </th>
                                <td>
								<input name="end" value={{management_alter[6][1]}} class="layui-input">
                              </td>
                            </tr>


                        </tbody>

                    </table>
                    <button onclick="ShowDiv()"  class="layui-btn" type="submit" id="alter_button" >确定</button>

                    </form>

                </div>


            </div>
        </div>
    </div>


</div>
 <script>
     function ShowDiv() {
        $('#alter_button').html("<img src=\"../static/images/hc.gif\" alt=\"\"/>操作中，请稍候...");
        $('#alter_button').css({"background-color":"grey"});
        }

 </script>

  <script>
                  if ({{warn}}==1){
                       layui.use(['laydate','form'], function() {
                           var laydate = layui.laydate;
                           var form = layui.form;
                           layer.msg('修改成功!', {icon: 6, time: 1000});
                       });
              }
            </script>

    <script>


      layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        var  form = layui.form;
        // 监听全选
                /*用户-修改权限*/
          form.on('select(business1)', function(obj){
           var menderPower =  parseInt($('#menderPower').attr('title'));
           var content =  obj.elem.value;
           layer.confirm('确认要修改吗？', function (index) {
           if(menderPower >= 2 ) {
               $.ajax({
                   //请求方式
                   type: "POST",
                   //请求的媒体类型
                   contentType: "application/json;charset=UTF-8",
                   //请求地址
                   url: "/setting_range",
                   //数据，json字符串
                   data: JSON.stringify({
                       'menderPower': menderPower,
                       'content': content
                   }),
                   //请求成功
                   success: function (result) {
                       if (result == "success") {
                           layer.msg('修改成功!', {icon: 6, time: 1000});
                       } else if (result == "fail") {
                           layer.open({
                               title: '警告',
                               content: '错误！！！'
                           });
                       }
                   },
                   //请求失败，包含具体的错误信息
                   error: function (e) {
                       console.log(e.status);
                       console.log(e.responseText);
                   }
               });
           }else{
                 layer.open({
                       title: '警告',
                       content: '无权限修改！'
				 });
           }
        });
});

          form.on('select(business2)', function(obj){
           var menderPower =  parseInt($('#menderPower').attr('title'));
           var content =  obj.elem.value;
           layer.confirm('确认要修改吗？', function (index) {
           if(menderPower >= 2 ) {
               $.ajax({
                   //请求方式
                   type: "POST",
                   //请求的媒体类型
                   contentType: "application/json;charset=UTF-8",
                   //请求地址
                   url: "/setting_province",
                   //数据，json字符串
                   data: JSON.stringify({
                       'menderPower': menderPower,
                       'content': content
                   }),
                   //请求成功
                   success: function (result) {
                       if (result == "success") {
                           layer.msg('修改成功!', {icon: 6, time: 1000});
                       } else if (result == "fail") {
                           layer.open({
                               title: '警告',
                               content: '错误！！！'
                           });
                       }
                   },
                   //请求失败，包含具体的错误信息
                   error: function (e) {
                       console.log(e.status);
                       console.log(e.responseText);
                   }
               });
           }else{
                 layer.open({
                       title: '警告',
                       content: '无权限修改！'
				 });
           }
        });
});

        //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
        });
      });





    </script>

  {% endblock %}
     {% block footer%}
    {% endblock %}